using System;
using System.Collections.Generic;
using System.Text;

namespace NBusiness.CodeDom
{
    [Serializable]
    public abstract class EntityRelationship : EntityCompileUnit, IHasParent, IValidatable, IInheritable, IAccessible
	{
		#region Member Properties and Fields
		private string _Name = null;

		public string Name
		{
			get { return _Name; }
			set { _Name = value; }
		}

        private Entity _From = null;

        public Entity From
        {
            get { return _From; }
            set { _From = value; }
        }

		private Entity _With = null;

		public Entity With
		{
			get { return _With; }
			set { _With = value; }
		}

		private Dictionary<EntityField, EntityField> _On = new Dictionary<EntityField, EntityField>();

		public Dictionary<EntityField, EntityField> On
		{
			get { return _On; }
		}

		private EntityRelationshipType _Type = EntityRelationshipType.Unknown;

		public EntityRelationshipType Type
		{
			get { return _Type; }
			set { _Type = value; }
		}

        private Entity _parent;
        public IHasParent Parent
        {
            get { return _parent; }
            set { _parent = (Entity)value; }
        }
		#endregion

		#region object overrides
		public override string ToString()
		{
			return Name;
		}
		public override bool Equals(object obj)
		{
			if (obj is EntityRelationship)
			{
				return Name.Equals((obj as EntityRelationship).Name);
			}
			else return false;
		}
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
		#endregion
	}
}
